####################################################################################
use_sample=`cat ${work_dir}/public_ref/TCGA/TCGA_STAD.TMB.tsv | grep -v bcr_patient_barcode | awk -F'\t' '{print $1"-01"}' | tr '\n' '|' | sed 's/|$//'`
use_sample_msi=`cat ${work_dir}/public_ref/TCGA/TCGA_STAD_msi.TMB.tsv | grep -v bcr_patient_barcode | awk -F'\t' '{print $1"-01"}' | tr '\n' '|' | sed 's/|$//'`

## 210人存在CNV数据
## 所有有突变的样本均有CNV数据
echo -e "Sample\tChromosome\tStart\tEnd\tNum_Probes\tSegment_Mean" > ${seg_public_path}/TCGA_use.seg
cat ${work_dir}/public_ref/TCGA/broad.mit.edu_PANCAN_Genome_Wide_SNP_6_whitelisted.seg | grep -E "${use_sample}|${use_sample_msi}" |\
sed 's/-01/\t/' | awk -F'\t' '{OFS="\t"}{print $1,$3,$4,$5,$6,$7}' >> ${seg_public_path}/TCGA_use.seg

####################################################################################
## 208人存在等位基因特异的拷贝数信息
## 肿瘤纯度
cat ${work_dir}/public_ref/TCGA/TCGA_mastercalls.abs_tables_JSedit.fixed.txt | awk -F'\t' '{OFS="\t"}{print $1,$4,$5}' | grep -E "purity|${use_sample}|${use_sample_msi}" | \
sed 's/-01//' > ${seg_public_path}/TCGA_purity.tsv
## 201人存在纯度的值

## 等位基因特异的拷贝数
cols="Sample\tChromosome\tStart\tEnd\tLength.snp."
cols=${cols}"\t""Corrected_Copy_Number\tCorrected_MajorCN\tCorrected_MinorCN\tCellular_Prevalence"
echo -e ${cols} > ${seg_public_path}/TCGA_use.absolute.seg
cat ${work_dir}/public_ref/TCGA/TCGA_mastercalls.abs_segtabs.fixed.txt | grep -E "${use_sample}|${use_sample_msi}" | \
awk -F'\t' '{OFS="\t"}{print $1,$2,$3,$4,$5,$9,$8,$7,$12}' | sed 's/-01//' >> ${seg_public_path}/TCGA_use.absolute.seg